package ast.statement.delete

import ast.expr.SqlBinaryExpr
import ast.expr.SqlBinaryOperator
import ast.expr.SqlExpr
import ast.statement.SqlStatement

/**
 * sql语法树：删除语句
 * @property table SqlExpr? 操作的表
 * @property where SqlExpr? 删除条件
 */
data class SqlDelete(var table: SqlExpr? = null, var where: SqlExpr? = null) : SqlStatement {
    /**
     * 添加合取条件
     * @param condition SqlExpr 条件表达式
     */
    fun addCondition(condition: SqlExpr) {
        where = if (where != null) {
            SqlBinaryExpr(where!!, SqlBinaryOperator.AND, condition)
        } else {
            condition
        }
    }
}